﻿using MediatR;
using Production_Get.API.Infrastructures.Interfaces;
using Return.Enum;
using THE_WIND_RISES.Common.Domans.Produce.DemandPlanning;
using THE_WIND_RISES.Common.Domans.Produce.ManifestInfos;
using THE_WIND_RISES.Common.Dtos;

namespace Production_Get.API.Application.MaterialManagement.Mang
{
    public class TaskMangHandler : IRequestHandler<TaskMangCommon, Result>
    {
        private readonly IBaseRepositoryGet<ProductionTasks> ProductionTasksRepository;
        public TaskMangHandler(IBaseRepositoryGet<ProductionTasks> productionTasksRepository)
        {
            ProductionTasksRepository= productionTasksRepository;
        }
        public async Task<Result> Handle(TaskMangCommon request, CancellationToken cancellationToken)
        {
            var result = new Result() { Code = (int)CommonErrorCodes.Search };
            string sql = "SELECT * FROM ProductionTasks Where TasksId=" + request.TasksId;
            var list = ProductionTasksRepository.GetAll(sql, default).FirstOrDefault();
            if (list != null)
            {
                result.Code = (int)CommonErrorCodes.Success;
                result.Data = list;
                result.Msg = "显示成功";
            }
            return result;
        }
    }
}
